package com.seewo.dubbo.debugger.api;


import java.util.Collection;

/**
 * @author chenliangliang
 * @date 2018/7/24
 */
public enum DataType {

    BYTE("byte"),
    SHORT("short"),
    INT("integer"),
    LONG("long"),
    FLOAT("float"),
    DOUBLE("double"),
    CHAR("char"),
    BOOLEAN("boolean"),
    ARRAY("array"),
    COLLECTION("collection"),
    OBJECT("object"),
    STRING("string"),
    VOID("void");

    private String val;

    DataType(String s) {
        val=s;
    }

    public String getValue() {
        return this.val;
    }

    public static String getType(Class<?> clazz){
        if (String.class.equals(clazz)){
            return STRING.getValue();
        }else if (void.class.equals(clazz)||Void.class.equals(clazz)){
            return VOID.getValue();
        }else if (int.class.equals(clazz)||Integer.class.equals(clazz)){
            return INT.getValue();
        }else if (long.class.equals(clazz)||Long.class.equals(clazz)){
            return LONG.getValue();
        }else if (boolean.class.equals(clazz)||Boolean.class.equals(clazz)){
            return BOOLEAN.getValue();
        }else if (float.class.equals(clazz)||Float.class.equals(clazz)){
            return FLOAT.getValue();
        }else if (double.class.equals(clazz)||Double.class.equals(clazz)){
            return DOUBLE.getValue();
        }else if (clazz.isArray()){
            return ARRAY.getValue();
        }else if(Collection.class.equals(clazz)){
            return COLLECTION.getValue();
        }else {
            return OBJECT.getValue();
        }
    }

    public static void main(String[] args) {
    }
}
